
using System;
using System.Collections.Generic;
/// <summary>
/// Xlsx表Db库帮助类【Select】
/// </summary>
public static partial class HFDbHelper
{
    /// <summary>
    /// 读取库
    /// </summary>
    /// <param name="_onComplete">完成回调</param>
    /// <param name="_onProgress">进度[string:信息,float:进度0-1]</param>
    static void OnReadMaster(Action _onComplete,Action<string, float> _onProgress)
    {
#if ILRuntime
        List<Func<bool>> calls = new List<Func<bool>>();
        
	calls.Add(() => { OnRead_Table_GameLanguage(); _onProgress?.Invoke("Read GameLanguage",1f); return true; });
        if (calls.Count > 0)
        {
            OnLoadToCache(calls, 0, _onComplete);
        }
        else
        {
            _onComplete?.Invoke();
        }
#else
	OnRead_Table_GameLanguage(); _onProgress?.Invoke("Read GameLanguage",1f);
	_onComplete?.Invoke();
#endif
    }
#if ILRuntime
    /// <summary>
    /// 加载配置到缓存
    /// </summary>
    /// <param name="_calls">回调</param>
    /// <param name="_index">索引</param>
	/// <param name="_onComplete">完成</param>
	static void OnLoadToCache(List<Func<bool>> _calls, int _index, Action _onComplete)
    {
        if (_calls.Count > _index)
        {
            bool nextStep = _calls[_index].Invoke();
            QKUCoroutineComponent.Instance.WaitOneFrame(() =>
            {
                if (nextStep)
                {
                    _index++;
                }
                OnLoadToCache(_calls, _index, _onComplete);
            });
        }
        else
        {
            _onComplete?.Invoke();
        }
    }
#endif
}